import { Pipe, PipeTransform } from '@angular/core';
import { ToolService } from '../service/tool.service';

@Pipe({
  name: 'decimal'
})
export class DecimalPipe implements PipeTransform {

  transform(value: any, args?: any): any {
    //四舍五入保留两位小数
    if(ToolService.isEmpty(value)){
        return 0;
    }
    if(args=='three'){
        return ToolService.keepThreeDecimal(value);
    }else if(args=='no'){
        return parseInt(value);
    }
    return ToolService.keepTwoDecimal(value);
  }

}
